Skip to main content

Recipe Change via HTTP with Node-RED

This tutorial shows you how to remotely change recipes on your OV20i camera using simple HTTP requests. You'll build a system that lets any device on your network switch between different inspection setups instantly - perfect for production lines with multiple products.

What You'll Build: A remote recipe switching system that responds to HTTP commands from tablets, computers, PLCs, or any device that can send web requests.

Estimated Time: 15-20 minutes

Skill Level: Beginner

Real Example: Imagine an operator scanning a barcode on their tablet, and the camera automatically switches to the right recipe for that product - that's exactly what we're building!

Why HTTP Recipe Changes Make Life Easy

The OV20i makes remote recipe switching simple:

  • Any device can trigger - tablets, PLCs, computers, even smartphones
  • Instant switching - recipes change in under a second
  • No complex setup - just a few nodes in Node-RED
  • Works with existing systems - integrates with what you already have

Perfect for: Multi-product lines, operator control panels, automated systems, or anywhere you need quick recipe changes.

Prerequisites

Before starting, make sure you have:

  • OV20i camera connected and working
  • At least 2 recipes created and ready to use
  • Node-RED access (through IO Block)
note

You'll need the recipe ID numbers - these are found in your browser's address bar when editing recipes.

Step 1: Find Your Recipe Numbers

1.1 Get Recipe IDs

  1. Open any recipe in Recipe Editor
  2. Look at your browser address bar
  3. Find the number after /recipe/ (example: /recipe/15 means Recipe ID is 15)
  4. Write down the IDs for all recipes you want to switch between

Why these numbers? Each recipe has a unique ID that never changes - this is what the camera uses internally.

Step 2: Open Node-RED

2.1 Access the Flow Builder

  1. In any Recipe Editor, click "IO Block"
  2. Click "Configure IO"

You're now in Node-RED where we'll build your recipe switching system!

2.2 Plan Your Setup

Here's what we're building:

Button Click → Format Request → Send to Camera → See Result

Simple! The camera has a built-in web server that listens for recipe change requests.

Step 3: Build Your Recipe Switcher

3.1 Add the Basic Nodes

Drag these 4 nodes onto your canvas:

  1. Inject (from Input section) - Your "switch recipe" button
  2. Function (from Function section) - Formats the request properly
  3. HTTP Request (from Network section) - Sends command to camera
  4. Debug (from Output section) - Shows if it worked

3.2 Connect Them Up

Wire them together like this:

Inject → Function → HTTP Request → Debug

Easy! Now let's configure each one.

Step 4: Configure Your Nodes

4.1 Set Up Your Recipe Button

  1. Double-click the Inject node
  2. Change name to "Switch to Recipe 15" (use your actual recipe ID)
  3. Set Payload to "15" (your recipe ID number)
  4. Click "Done"

4.2 Set Up the Request Formatter

  1. Double-click the Function node
  2. Name it "Format Request"
  3. Copy this simple code:
// Get recipe number from button
let recipeID = msg.payload;

// Set up the web request
msg.headers = {'Content-Type': 'application/json'};
msg.payload = JSON.stringify({ id: recipeID });

return msg;

  1. Click "Done"

What this does: Takes your recipe number and packages it the way the camera expects.

4.3 Set Up the HTTP Request

  1. Double-click the HTTP Request node
  2. Set Method to "POST"
  3. Set URL to localhost:5001/pipeline/activate
  4. Name it "Change Recipe"
  5. Click "Done"
note

Before version 18.92: use http://[CAMERA_IP]/edge/pipeline/activate Version 18.92 and later: use http://localhost:5001/pipeline/activate

4.4 Set Up the Response Monitor

  1. Double-click the Debug node
  2. Name it "Recipe Change Result"
  3. Click "Done"

Perfect! Your recipe switcher is ready to test.

Step 5: Test Your Recipe Switcher

5.1 Deploy and Try It

  1. Click the red "Deploy" button
  2. Click your inject button (Switch to Recipe 15)
  3. Watch the debug panel for the response

5.2 Check If It Worked

Success signs:

  • Debug shows "success": true
  • Camera interface shows new recipe name
  • No error messages in debug panel

If it worked: Congratulations! You just remotely switched recipes.

If not: Check the troubleshooting section below.

5.3 Add More Recipe Buttons

Want multiple recipes? Just add more inject nodes:

  • Recipe 10 button: Payload = "10", Name = "Switch to Recipe 10"
  • Recipe 23 button: Payload = "23", Name = "Switch to Recipe 23"
  • All connect to the same Function node

Step 6: Use from Other Devices

Now the fun part! Any device can change recipes by sending web requests to your camera.

6.1 From Any Web Browser

Type this in any browser on your network:

http://192.168.0.100:5001/pipeline/activate

(Replace with your camera's IP address)

6.2 From Command Line

Windows/Mac/Linux - change to recipe 15:

curl -X POST http://192.168.0.100:5001/pipeline/activate \
-H "Content-Type: application/json" \
-d '{"id": "15"}'

6.3 From PLCs and Other Systems

Most modern systems can send HTTP requests:

  • Siemens PLCs: Use HTTP client blocks
  • Allen-Bradley: Use HTTP instruction blocks
  • Python/C#/Java: Use standard HTTP libraries
  • Custom apps: Any programming language works

The request format is always the same:

  • Method: POST
  • URL: http://[CAMERA_IP]:5001/pipeline/activate
  • Body: {"id": "RECIPE_NUMBER"}

Step 7: Make It Even Better

7.1 Add Recipe Validation

Want to prevent switching to non-existent recipes? Modify your function:

let recipeID = msg.payload;
let validRecipes = ["10", "15", "20"]; // Your actual recipe IDs

if (!validRecipes.includes(recipeID)) {
msg.payload = "Invalid recipe: " + recipeID;
return null; // Don't send request
}

// Normal formatting continues...

7.2 Product Code Mapping

Want to use product names instead of numbers? Try this:

let productCodes = {
"BOLT_A": "10",
"BOLT_B": "15",
"SCREW_C": "20"
};

let recipeID = productCodes[msg.payload];
// Continue with formatting...

Now you can trigger with product names instead of numbers!

7.3 Response Processing

Want better success/error messages? Add another function after HTTP Request:

let response = JSON.parse(msg.payload);

if (response.success) {
msg.payload = "✓ Recipe changed successfully!";
} else {
msg.payload = "✗ Recipe change failed: " + response.error;
}

return msg;

Step 8: Quick Troubleshooting

Not working? Here are the most common fixes:

ProblemQuick Fix
"Recipe not found" errorDouble-check your recipe ID number in the URL
No response at allVerify camera IP address and network connection
"Parse error" messageCheck that Function node code is copied correctly
Recipe doesn't actually changeMake sure the recipe exists and is not corrupted

Still stuck? Check that your camera is online and accessible from Node-RED.

You Did It!

Congratulations! You now have remote recipe control of your OV20i camera. With just a few clicks, you built a system that can:

  • Switch recipes instantly from any device on your network
  • Integrate with existing systems like PLCs, tablets, or computers
  • Support multiple recipes with simple button clicks
  • Validate requests to prevent errors
  • Work with custom applications using standard web technology

What's Next?

Now that you have the basics working, you can:

Easy Next Steps

  • Add more recipe buttons for all your products
  • Test from different devices like tablets or phones
  • Create custom product mappings for easier operation

Advanced Ideas

  • Build operator dashboards with recipe selection buttons
  • Connect to barcode scanners for automatic recipe selection
  • Integrate with MES systems for production line coordination
  • Add logging to track which recipes are used when

Real-World Examples

Here's how others use HTTP recipe switching:

  • Food Packaging: Barcode scanner triggers recipe change for different package sizes
  • Automotive: PLC switches recipes based on part type coming down the line
  • Electronics: Operator tablet with recipe buttons for different circuit boards
  • Quality Control: Automatic recipe switching based on production schedule

The possibilities are endless - and it all starts with the simple system you just built!

🔗 See Also